package com.gujiangbo.tools;

import java.util.HashMap;

/**
 * @Author: gujiangbo.co
 * @Contact: 646832012@qq.com
 * @Date: 2022/1/10 16:01
 * @Version: 1.0
 * @Description:
 */
public class DataUtils {


    // 交换两个数据值
    public static void swap(int a, int b) {
        System.out.println("交换之前：" + a + " " + b);
        a = a ^ b;
        b = a ^ b;
        a = a ^ b;
        System.out.println("交换之后：" + a + " " + b);
    }

    public static void reverse_array(int a[], int cnt) {
        int first = 0, last = cnt - 1;
        do {
            swap(a[first], a[last]);
            first++;
            last--;
        } while (first <= last);
    }


    public static void main(String[] args) {
        //swap(1, 2);
        reverse_array(new int[]{1, 2, 3, 4}, 3);
    }
}
